package com.example.app.retrofit2.api;

import android.content.Context;

import com.example.app.retrofit2.bean.LoginResultBean;
import com.example.app.retrofit2.bean.LoginSendBean;

import java.util.Map;

import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class ApiClient2 {
    private Retrofit mRetrofit;
    private Api2 mApi;
    private static ApiClient2 sApiClient;
    private ApiClient2(final Context context){
        mRetrofit = new Retrofit.Builder().baseUrl(GetApi2.baseURL)
                .addConverterFactory(GsonConverterFactory.create()).build();
        mApi = mRetrofit.create(Api2.class);
    }

    public static ApiClient2 getInstance(Context context){
        if (sApiClient == null)
            sApiClient = new ApiClient2(context);
        return sApiClient;
    }
    public static void destroyInstance(){
        if (sApiClient!=null){
            sApiClient = null;
        }
    }
    public String getRootURL(){
        return GetApi2.baseURL;
    }
    public Call<LoginResultBean> getReturnData(Map<String,String> map, LoginSendBean loginSendBean){
        return mApi.login(map,loginSendBean);
    }
}
